package com.xjc.business.controller.stu;

import com.xjc.business.entity.vo.NewsVo;
import com.xjc.business.service.SchoolNewsService;
import com.xjc.system.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 徐锦程
 * 时间:2025-02-04 19:30
 */
@RestController
@RequestMapping("/student/home")
public class HomeController {

    @Autowired
    SchoolNewsService schoolNewsService;

    /**
     * 首页新闻列表
     * @param id 微信id
     * @return 新闻列表
     */
    @GetMapping("/newsList/{id}")
    public Result<List<NewsVo>> getNewsList(@PathVariable(value = "id",required = false) Integer id) {
        return schoolNewsService.getNewsList(id);
    }

    /**
     * 获取新闻内容
     * @param id 新闻id
     * @return 内容
     */
    @RequestMapping("/content/{id}")
    public Result<String> getNewsContent(@PathVariable(value = "id",required = false) Integer id){
        return Result.okWithData(schoolNewsService.getById(id).getContent());
    }
}
